/* START 1c_tripTimesAroundOpening.do */

/* INCLUDED AS FILE IN 1_tripCountsByDayAroundOpening.do */

fv

preserve
gcollapse (mean) t (count) trips = oa, ///
  by(JRNY_ORIG_ID_NUM JRNY_DEST_ID_NUM op dp after)
/* gcollapse (sum) totTrips = trips, /// */
  /* by(JRNY_ORIG_ID_NUM JRNY_DEST_ID_NUM op dp) merge */
hashsort op dp -trips after

drop if op == . | dp == .

frame copy default before
fv before
keep if after == 0
gduplicates drop op dp, force
ren t t0
fv default
frlink m:1 JRNY_ORIG_ID_NUM JRNY_DEST_ID_NUM, frame(before)
frame put if before != ., into(matched)
fv matched
drop before
hashsort op dp after
save "${dropbox}/commuteTimesModesStopsBefore.dta", replace

fv
